﻿using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Office.Interop.Word;

namespace WFL.Office.Word
{
    public class TableColumn
    {
        private readonly object _lock = new object();

        private WordBorders _borders;
        public WordBorders Borders
        {
            get
            {
                if (_borders == null)
                {
                    lock (_lock) { if (_borders == null) { _borders = new WordBorders(_column.Borders); } }
                }
                return _borders;
            }
        }

        private TableCells _cells;
        public TableCells Cells
        {
            get
            {
                if (_cells == null)
                {
                    lock (_lock) { if (_cells == null) { _cells = new TableCells(_column.Cells) { Table = Table }; } }
                }
                return _cells;
            }
        }

        public float Width
        {
            get { return _column.Width; }
            set { _column.Width = value; }
        }

        internal Column _column
        {
            get;
            private set;
        }

        public WordTable Table
        {
            get;
            internal set;
        }

        internal TableColumn(Column column)
        {
            _column = column;
        }

        public void SetWidth(float columnWidth, RulerStyle rulerStyle)
        {
            _column.SetWidth(columnWidth, (WdRulerStyle)rulerStyle);
        }

    }
}
